$(document).ready(function() {
	$("#demo").validate({
		rules:{
			"majorGroup.majorgroupName": {
				required: true,
	    		maxlength: 30
			},
			"majorGroup.majorgroupRemark":{
				required: false,
	    		maxlength: 500
			},
			"majorGroup.departmentId":{
				required: true
			}
		}
	});
});

//返回department的json数据，带被选择数据
function queryDepartmentList(departmentId){
	$.post(
		"../AjaxResultData/listAllDepartment.action",
		function(data){
			var departmentData = eval("("+data.departmentData+")");  
			$("#departmentId").append("<option value=''>--未选择--</option>");
			for(var i = 0;i<departmentData.length;i++){
				if(departmentId==departmentData[i].departmentId){
					$("#departmentId").append("<option value='"+departmentData[i].departmentId+"' selected='selected'>"+departmentData[i].departmentName+"</option>");
				}else{
					$("#departmentId").append("<option value='"+departmentData[i].departmentId+"'>"+departmentData[i].departmentName+"</option>");
				}
			}
		},
			"json"
	);
}